<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <input type="text" name="title" />
    <span></span>
    <script>
      let arr = ["hdcms", "houdunren"];
      // every顾名思义，所有的元素经过filter为真才是真
      let flag = arr.every((item) => item.length > 1);
      console.log(flag);

      // some 顾名思义，只要有一个为真，就是真
      let test = arr.some((item) => item.length > 6);
      console.log(test);

      let keywords = ["js", "java"];
      let title = document.querySelector('[name="title"]');

      title.addEventListener("keyup", function () {
        let a = keywords.some((item) => this.value.indexOf(item) != -1);
        if (a == false) {
          document.querySelector("span").innerHTML = "必须包含关键字";
        } else {
          document.querySelector("span").innerHTML = "";
        }
      });
    </script>
  </body>
</html>
